package com.ssy.lingxi.member.merchant.api.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 会员层级关系（关联类型）枚举
 * @author 万宁
 * @version 2.0.0
 * @date 2020-08-18
 */
public enum MemberRelationTypeEnum {

    /**
     * 上级会员，或归属会员是平台 - 0
     */
    PLATFORM(0, "上级会员是平台会员"),

    /**
     * 上级会员，或归属会员是商户会员或渠道会员 - 1
     */
    OTHER(1, "上级会员是商户会员或渠道会员");

    private final Integer code;

    MemberRelationTypeEnum(Integer code, String message) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.getCode());
    }

    public static MemberRelationTypeEnum parse(Integer code) {
        return Arrays.stream(MemberRelationTypeEnum.values()).filter(t -> t.getCode().equals(code)).findFirst().orElse(MemberRelationTypeEnum.PLATFORM);
    }
}
